#ifndef XML_PARSER_H_
#define XML_PARSER_H_

/*
 *	Source: http://www.yolinux.com/TUTORIALS/XML-Xerces-C.html
 */

/**
 *  @file
 *  Class "XMLParser" provides the functions to read the XML data.
 */
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMDocumentType.hpp>
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMNodeIterator.hpp>
#include <xercesc/dom/DOMNodeList.hpp>
#include <xercesc/dom/DOMText.hpp>

#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLUni.hpp>

#include <string>
#include <stdexcept>
#include <vector>

#include "Game_Config.h"
#include "Monster.h"
#include "Item.h"
#include "Terrain.h"
#include "Map.h"
#include "MapCell.h"
#include "Class.h"
#include "Player.h"




/**
 * XML Parser
 * is used to load Game information
 */
class XMLParser
{
public:
	XMLParser();
	XMLParser(char* strRoot, char* strAppSettings); 
	XMLParser(char* strRoot, char* strAppSettings, char* strAppSettings2);
	~XMLParser();
	void XMLParser_Init();
	void addATTROption(char* strOption);
	void readLevelingConfigFile(const char* configFile, std::vector<int>& vecResult);
	void readMonsterConfigFile(const char * configFile, std::vector<Monster*>& vecResult);
	void readItemConfigFile(const char * configFile, std::vector<Item*>& vecResult);
	void readItemsForMonsters(const char * configFile, std::vector<s_ItemsForMonster*>& vecResult);
	void readTerrainConfigFile(const char * configFile, std::vector<Terrain*>& vecResult);
	void readMapConfigFile(const char * configFile, std::vector<Map*>& vecResult);
	void readClassConfigFile(const char * configFile, std::vector<Class*>& vecResult);
	void readPlayerConfigFile(const char * configFile, Player* const player);
	void readClassFromPlayerConfigFile(const char * configFile, std::string& strClassName);

private:
	xercesc::XercesDOMParser *m_ConfigFileParser;		//!< Parser configuration
	// Internal class use only. Hold Xerces data in UTF-16 SMLCh type.
	XMLCh*				m_TAG_root;						//!< Root Element
	XMLCh*				m_TAG_ApplicationSettings;		//!< 1st Element
	XMLCh*				m_TAG_ApplicationSettings2;		//!< 2nd Element
	std::vector<XMLCh*>	m_ATTR_Options;					//!< Attibutes

	int checkFile(const char* fileName);
};
#endif  // XML_PARSER_H_
